package com.accp.demo.controller.base;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.accp.demo.pojo.base.Material;
import com.accp.demo.pojo.base.Unit;
import com.accp.demo.service.base.MaterielService;


/*
 * 物料主文件控制器
 */
@RestController
@RequestMapping("/materielcontrollera/")
public class MaterielController {

	@Autowired
	private MaterielService materielService;
	
	
		//计量单位查询全部
		@RequestMapping("queryunit")
		public List<Unit> quryunitall(){
			return materielService.queryunitall1();
		}
		
		//物料主文件新增
		@RequestMapping("add")
		@ResponseBody
		public Object addmateriel(@RequestBody Material materiel){
			System.out.println(materiel);
			Material  aa=new Material();
			//aa.setMaterialNo(materialNo);
			System.out.println(materiel.getMaterialNo());
			materielService.savemateriel(materiel);
			//System.out.println(map.entrySet());
			return "新增成功";
		}
		
		@RequestMapping("querymateriel")
		@ResponseBody
		public Material querymateriel(String materialNo){
			
			return materielService.queryMatByNo(materialNo);
			
		};
		
		//物料主文件修改
		@RequestMapping("update")
		@ResponseBody
		public Integer updatemateriel(Material materiel){
			return materielService.updatemateriel(materiel);
		}
		
		//物料主文件删除
		public Integer delete(String materialNo){
			return materielService.deletemateriel(materialNo);
		}
}
